﻿using System.Threading;

namespace PortableTPL
{
    public class SynchronisationContextTaskScheduler : TaskScheduler
    {
        readonly SynchronizationContext context;
        internal SynchronisationContextTaskScheduler(SynchronizationContext context)
        {
            this.context = context;
        }

        public override void EnqueueTask(Task task)
        {
            context.Post(state=> task.DoWork(), null);
        }

        public override void Dispose()
        {            
        }
    }
}
